package com.example.demo.threadDemo.aCreateThreadName;

/**
 * @Description DemoSleep01
 * @Author songchuanlong
 * @Date 2025-04-14
 */


/**
 * 线程的sleep方法和join方法
 */
public class DemoSleep01 {
    public static void main(String[] args) throws Exception {
        //线程sleep
        for (int i = 1; i <=5; i++) {
            System.out.println(i);
            if(i==3){
                Thread.sleep(5000);
            }
        }

        //join方法作用:让当前调用这个方法的线程先执行完。

        MySleepThread01 aaaaaa = new MySleepThread01("AAAAAA");
        aaaaaa.start();
        aaaaaa.join();
        MySleepThread01 bbbbbb = new MySleepThread01("BBBBBB");
        bbbbbb.start();
        bbbbbb.join();

    }
}
